//
//  NRWMissionCenterVC.m
//  Finance
//
//  Created by 邢毅 on 2018/7/31.
//  Copyright © 2018年 com.anpxd. All rights reserved.
//

#import "NRWMissionCenterVC.h"
#import "NRWCenterCell.h"

@interface NRWMissionCenterVC ()<UICollectionViewDelegate, UICollectionViewDataSource>

@property (strong, nonatomic) NSArray<NSDictionary *> *pageDataSource;

@end

@implementation NRWMissionCenterVC
{
	UICollectionView *_collectionView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
	
	self.navigationView.title = @"任务中心";
	
	[self setupUI];
}

- (void)setupUI {
	
	UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
	layout.minimumLineSpacing = 0;
	layout.minimumInteritemSpacing = 0;
	layout.itemSize = CGSizeMake(SCREEN_WIDTH() / 3, 140);

	_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, getNavHeight(), SCREEN_WIDTH(), SCREEN_HEIGHT() - getNavHeight()) collectionViewLayout:layout];
	_collectionView.backgroundColor = [UIColor whiteColor];
	_collectionView.delegate = self;
	_collectionView.dataSource = self;
	[_collectionView registerClass:NRWCenterCell.class forCellWithReuseIdentifier:@"cell"];
	[self.view addSubview:_collectionView];
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
	
	return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
	
	return self.pageDataSource.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
	
	NRWCenterCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
	
	cell.imageName = self.pageDataSource[indexPath.item][@"imageName"];
	cell.titleString = self.pageDataSource[indexPath.item][@"title"];
	
	return cell;
}

#pragma mark - getter
- (NSArray<NSDictionary *> *)pageDataSource {
	
	if (_pageDataSource == nil) {
		_pageDataSource = @[
							@{@"imageName": @"mission_wait",
							  @"title": @"待办任务"},
							@{@"imageName": @"mission_completed",
							  @"title": @"已完结任务"}
							];
	}
	return _pageDataSource;
}

@end
